from multiprocessing import Process
import os
import time


def sub_process1(name):
    print(f'我是子进程,我的PID是:{os.getpid()}, 我的父进程是:{os.getppid()},----------{name}')
    time.sleep(1)


def sub_process2(age):
    print(f'我是子进程,我的PID是:{os.getpid()}, 我的父进程是:{os.getppid()},----------{age}')
    time.sleep(1)


if __name__ == '__main__':
    print('父进程开始执行')
    for i in range(5):
        # p1 = Process()  # 没有给定target参数 默认执行run方法
        # p2 = Process()
        # p1.start()
        # p2.start()
        # p1.run()
        # p2.run()
        p1 = Process(target=sub_process1, args=('duiduo',))
        p2 = Process(target=sub_process2, args=(18,))
        p1.start()
        p2.start()

        # 终止进程
        p1.terminate()
        p2.terminate()
    print('父进程执行结束')
